package com.nursing.controller.admin;

import com.nursing.bean.Admin;
import com.nursing.model.Result;
import com.nursing.model.vo.admin.AdminLoginVo;
import com.nursing.service.AdminService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin")
public class AdminUserController {
    private final AdminService service;
    @Autowired
    public AdminUserController(AdminService service) {
        this.service = service;
    }

    @PostMapping("/login")
    @ApiOperation("用户登录")
    public Result<Admin> Login(@RequestBody AdminLoginVo adminLoginVo){
        String username = adminLoginVo.getUsername();
        String password = adminLoginVo.getPassword();
        return this.service.login(username,password);
    }

    @PostMapping("/changePassword")
    @ApiOperation("修改密码")
    public Result<Admin> changePassword(@RequestBody Admin admin){
        return service.changePassword(admin);
    }
}
